let initdata = {
    name:"zhangsan",
    age:"20",
    address:"北京市昌平区",
    arr:[]
}
let appreducer = (state=initdata,action)=>{
    console.log(action);
    if (action.type === "setname") {
         state.name = "lisi"
         return state
    } else if (action.type === "setage") {
        let newage = action.payload
        return {
            ...state,
            age:newage
        }
    } else if (action.type === "setAddress") {
        let newAddress = action.payload;
        return {
            ...state,
            address:newAddress
        }
    }  else if (action.type === "getcarlist") {
         let newarr = action.payload
         return {
             ...state,
             arr:newarr
         }
    }

    else {
       
        return state
    }
   
}
export default appreducer